# include <cstdio>
# include <string>
# include <iostream>
using namespace std;

struct student { 
    char name[25];
    int pj, py, lw;
    bool gb, xb;
} s[124];
char gb[2], xb[2];

void input(student &a) { 
    scanf("%s %d %d %s %s %d", a.name, &a.pj, &a.py, gb, xb, &a.lw);
    if(gb[0] == 'Y') a.gb = 1;
    else a.gb = 0;
    if(xb[0] == 'Y') a.xb = 1;
    else a.xb = 0;
}

int AddScore(student a) { 
    int score = 0;
    if(a.pj > 80 && a.lw) score += 8000;
    if(a.pj > 85 && a.py > 80) score += 4000;
    if(a.pj > 90) score += 2000;
    if(a.pj > 85 && a.xb) score += 1000;
    if(a.py > 80 && a.gb) score += 850;
    return score;
}

int n, mx, sum, tmp;
char *ans;

int main() { 
    freopen("scholar.in", "r", stdin);
    freopen("scholar.out", "w", stdout);
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) { 
        input(s[i]);
        tmp = AddScore(s[i]);
        if(tmp > mx) { 
            ans = s[i].name;
            mx = tmp;
        }
        sum += tmp;
    }
    printf("%s\n%d\n%d\n", ans, mx, sum);
}
